<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>全局过滤器</title>
    <script src="/js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="msg">
        <!-- 使用过滤器 -->
        {{msg|upperCase|asterisk}}
    </div>
</body>

<script>
    //声明全局过滤器
    Vue.filter('upperCase',function(val){
        return val.toUpperCase();
    })
    Vue.filter('asterisk',function(val){
        var reg =/\d/g;
        return val.replace(reg,'*');
    })
   let vm=new Vue({
      el: '#app',
      data: {
        msg: ''
      }
   })
</script>

</html>